using DataDynamics.ActiveReports;
using DataDynamics.ActiveReports.Export.Xls;
using SM.core;
using SS;
using SS.core;
using System;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;
using TVSBH.core;
namespace TVSBH.func
{
	public class frmRepOutputRetail : Form
	{
		private IContainer components = null;
		private GroupBox groupBox3;
		private DateTimePicker dtpSelectMonth;
		private System.Windows.Forms.Label label17;
		private DataGridView dgvBill;
		private Button btnClose;
		private Button btnPrint;
		private ComboBox cbbAccount;
		private System.Windows.Forms.CheckBox ckbSelectAccount;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
		private DataGridViewTextBoxColumn Column15;
		private DataGridViewTextBoxColumn Column18;
		private DataGridViewTextBoxColumn Column10;
		private DataGridViewTextBoxColumn Column11;
		private DataGridViewTextBoxColumn Column12;
		private DataGridViewTextBoxColumn Column13;
		private DataGridViewTextBoxColumn Column14;
		private DataGridViewTextBoxColumn Column16;
		private DataGridViewTextBoxColumn Column17;
		private DataGridViewTextBoxColumn Column19;
		private DataGridViewTextBoxColumn Column24;
		private DataGridViewTextBoxColumn Column25;
		private DataGridViewTextBoxColumn Column26;
		private Button btnExportToExcel;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label lblSumMonneyInMonth;
		private System.Windows.Forms.Label lblMonth;
		private System.Windows.Forms.Label label6;
		private System.Windows.Forms.Label lblSumMoneyInDay;
		private System.Windows.Forms.Label lblDay;
		private GroupBox groupBox1;
		private Func objFunc = new Func();
		private DataTable objTable = new DataTable();
		private DataTable objTableBill = new DataTable();
		private Bill objBill = new Bill();
		private Partner objPartner = new Partner();
		private customers objCus = new customers();
		public string userName = "";
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			DataGridViewCellStyle dataGridViewCellStyle = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle2 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle3 = new DataGridViewCellStyle();
			DataGridViewCellStyle dataGridViewCellStyle4 = new DataGridViewCellStyle();
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(frmRepOutputRetail));
			this.groupBox3 = new GroupBox();
			this.ckbSelectAccount = new System.Windows.Forms.CheckBox();
			this.cbbAccount = new ComboBox();
			this.dtpSelectMonth = new DateTimePicker();
			this.label17 = new System.Windows.Forms.Label();
			this.dgvBill = new DataGridView();
			this.dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
			this.dataGridViewTextBoxColumn7 = new DataGridViewTextBoxColumn();
			this.Column15 = new DataGridViewTextBoxColumn();
			this.Column18 = new DataGridViewTextBoxColumn();
			this.Column10 = new DataGridViewTextBoxColumn();
			this.Column11 = new DataGridViewTextBoxColumn();
			this.Column12 = new DataGridViewTextBoxColumn();
			this.Column13 = new DataGridViewTextBoxColumn();
			this.Column14 = new DataGridViewTextBoxColumn();
			this.Column16 = new DataGridViewTextBoxColumn();
			this.Column17 = new DataGridViewTextBoxColumn();
			this.Column19 = new DataGridViewTextBoxColumn();
			this.Column24 = new DataGridViewTextBoxColumn();
			this.Column25 = new DataGridViewTextBoxColumn();
			this.Column26 = new DataGridViewTextBoxColumn();
			this.btnClose = new Button();
			this.btnPrint = new Button();
			this.btnExportToExcel = new Button();
			this.label1 = new System.Windows.Forms.Label();
			this.lblDay = new System.Windows.Forms.Label();
			this.lblSumMoneyInDay = new System.Windows.Forms.Label();
			this.lblSumMonneyInMonth = new System.Windows.Forms.Label();
			this.lblMonth = new System.Windows.Forms.Label();
			this.label6 = new System.Windows.Forms.Label();
			this.groupBox1 = new GroupBox();
			this.groupBox3.SuspendLayout();
			((ISupportInitialize)this.dgvBill).BeginInit();
			this.groupBox1.SuspendLayout();
			base.SuspendLayout();
			this.groupBox3.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.groupBox3.Controls.Add(this.ckbSelectAccount);
			this.groupBox3.Controls.Add(this.cbbAccount);
			this.groupBox3.Controls.Add(this.dtpSelectMonth);
			this.groupBox3.Controls.Add(this.label17);
			this.groupBox3.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.groupBox3.Location = new System.Drawing.Point(7, 5);
			this.groupBox3.Name = "groupBox3";
			this.groupBox3.Size = new Size(559, 81);
			this.groupBox3.TabIndex = 42;
			this.groupBox3.TabStop = false;
			this.groupBox3.Text = "Tìm kiếm";
			this.ckbSelectAccount.AutoSize = true;
			this.ckbSelectAccount.Font = new Font("Arial", 9f);
			this.ckbSelectAccount.Location = new System.Drawing.Point(216, 50);
			this.ckbSelectAccount.Name = "ckbSelectAccount";
			this.ckbSelectAccount.Size = new Size(83, 19);
			this.ckbSelectAccount.TabIndex = 32;
			this.ckbSelectAccount.Text = "Xem tất cả";
			this.ckbSelectAccount.UseVisualStyleBackColor = true;
			this.ckbSelectAccount.CheckedChanged += new EventHandler(this.ckbSelectAccount_CheckedChanged);
			this.cbbAccount.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbbAccount.Font = new Font("Arial", 9f);
			this.cbbAccount.FormattingEnabled = true;
			this.cbbAccount.Location = new System.Drawing.Point(216, 21);
			this.cbbAccount.Name = "cbbAccount";
			this.cbbAccount.Size = new Size(314, 23);
			this.cbbAccount.TabIndex = 31;
			this.cbbAccount.SelectedIndexChanged += new EventHandler(this.cbbAccount_SelectedIndexChanged);
			this.dtpSelectMonth.CustomFormat = "dd/MM/yyyy";
			this.dtpSelectMonth.Font = new Font("Arial", 9f);
			this.dtpSelectMonth.Format = DateTimePickerFormat.Custom;
			this.dtpSelectMonth.Location = new System.Drawing.Point(111, 22);
			this.dtpSelectMonth.Name = "dtpSelectMonth";
			this.dtpSelectMonth.Size = new Size(99, 21);
			this.dtpSelectMonth.TabIndex = 29;
			this.dtpSelectMonth.ValueChanged += new EventHandler(this.dtpSelectMonth_ValueChanged);
			this.label17.AutoSize = true;
			this.label17.Font = new Font("Arial", 9f);
			this.label17.ForeColor = Color.Black;
			this.label17.Location = new System.Drawing.Point(35, 24);
			this.label17.Name = "label17";
			this.label17.Size = new Size(72, 15);
			this.label17.TabIndex = 30;
			this.label17.Text = "Chọn ngày :";
			this.dgvBill.AllowUserToAddRows = false;
			this.dgvBill.AllowUserToDeleteRows = false;
			this.dgvBill.AllowUserToOrderColumns = true;
			this.dgvBill.AllowUserToResizeColumns = false;
			this.dgvBill.AllowUserToResizeRows = false;
			dataGridViewCellStyle.BackColor = Color.FromArgb(192, 255, 255);
			dataGridViewCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvBill.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle;
			this.dgvBill.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.dgvBill.BackgroundColor = Color.White;
			this.dgvBill.BorderStyle = BorderStyle.Fixed3D;
			this.dgvBill.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
			this.dgvBill.Columns.AddRange(new DataGridViewColumn[]
			{
				this.dataGridViewTextBoxColumn1,
				this.dataGridViewTextBoxColumn7,
				this.Column15,
				this.Column18,
				this.Column10,
				this.Column11,
				this.Column12,
				this.Column13,
				this.Column14,
				this.Column16,
				this.Column17,
				this.Column19,
				this.Column24,
				this.Column25,
				this.Column26
			});
			this.dgvBill.Cursor = Cursors.Hand;
			this.dgvBill.EnableHeadersVisualStyles = false;
			this.dgvBill.Location = new System.Drawing.Point(7, 92);
			this.dgvBill.MultiSelect = false;
			this.dgvBill.Name = "dgvBill";
			this.dgvBill.ReadOnly = true;
			this.dgvBill.RowHeadersVisible = false;
			this.dgvBill.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
			dataGridViewCellStyle2.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvBill.RowsDefaultCellStyle = dataGridViewCellStyle2;
			this.dgvBill.RowTemplate.DefaultCellStyle.Font = new Font("Arial", 9.75f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.dgvBill.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
			this.dgvBill.Size = new Size(886, 468);
			this.dgvBill.TabIndex = 41;
			this.dataGridViewTextBoxColumn1.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn1.DataPropertyName = "ID";
			this.dataGridViewTextBoxColumn1.HeaderText = "Hoá đơn";
			this.dataGridViewTextBoxColumn1.MinimumWidth = 120;
			this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
			this.dataGridViewTextBoxColumn1.ReadOnly = true;
			this.dataGridViewTextBoxColumn1.Width = 120;
			this.dataGridViewTextBoxColumn7.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.dataGridViewTextBoxColumn7.DataPropertyName = "CreateDate";
			dataGridViewCellStyle3.Format = "D";
			dataGridViewCellStyle3.NullValue = null;
			this.dataGridViewTextBoxColumn7.DefaultCellStyle = dataGridViewCellStyle3;
			this.dataGridViewTextBoxColumn7.HeaderText = "Ngày lập";
			this.dataGridViewTextBoxColumn7.MinimumWidth = 130;
			this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
			this.dataGridViewTextBoxColumn7.ReadOnly = true;
			this.dataGridViewTextBoxColumn7.Width = 130;
			this.Column15.DataPropertyName = "_Name";
			this.Column15.HeaderText = "Khách hàng";
			this.Column15.MinimumWidth = 200;
			this.Column15.Name = "Column15";
			this.Column15.ReadOnly = true;
			this.Column15.Width = 200;
			this.Column18.DataPropertyName = "_Address";
			this.Column18.HeaderText = "Địa chỉ";
			this.Column18.MinimumWidth = 150;
			this.Column18.Name = "Column18";
			this.Column18.ReadOnly = true;
			this.Column18.Width = 150;
			this.Column10.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.Column10.DataPropertyName = "TotalMoney";
			dataGridViewCellStyle4.Alignment = DataGridViewContentAlignment.MiddleRight;
			dataGridViewCellStyle4.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			this.Column10.DefaultCellStyle = dataGridViewCellStyle4;
			this.Column10.HeaderText = "Tổng tiền";
			this.Column10.MinimumWidth = 100;
			this.Column10.Name = "Column10";
			this.Column10.ReadOnly = true;
			this.Column11.DataPropertyName = "TypeInput";
			this.Column11.HeaderText = "TypeInput";
			this.Column11.Name = "Column11";
			this.Column11.ReadOnly = true;
			this.Column11.Visible = false;
			this.Column12.DataPropertyName = "WID";
			this.Column12.HeaderText = "WID";
			this.Column12.Name = "Column12";
			this.Column12.ReadOnly = true;
			this.Column12.Visible = false;
			this.Column13.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.Column13.DataPropertyName = "Note";
			this.Column13.HeaderText = "Diễn giải";
			this.Column13.MinimumWidth = 100;
			this.Column13.Name = "Column13";
			this.Column13.ReadOnly = true;
			this.Column14.DataPropertyName = "PID";
			this.Column14.HeaderText = "PID";
			this.Column14.Name = "Column14";
			this.Column14.ReadOnly = true;
			this.Column14.Visible = false;
			this.Column16.HeaderText = "Tuổi";
			this.Column16.Name = "Column16";
			this.Column16.ReadOnly = true;
			this.Column16.Visible = false;
			this.Column17.HeaderText = "Giới tính";
			this.Column17.Name = "Column17";
			this.Column17.ReadOnly = true;
			this.Column17.Visible = false;
			this.Column19.HeaderText = "Điện thoại";
			this.Column19.Name = "Column19";
			this.Column19.ReadOnly = true;
			this.Column19.Visible = false;
			this.Column24.DataPropertyName = "UserName";
			this.Column24.HeaderText = "UserName";
			this.Column24.Name = "Column24";
			this.Column24.ReadOnly = true;
			this.Column24.Visible = false;
			this.Column25.DataPropertyName = "FullName";
			this.Column25.HeaderText = "FullName";
			this.Column25.Name = "Column25";
			this.Column25.ReadOnly = true;
			this.Column25.Visible = false;
			this.Column26.DataPropertyName = "Printed";
			this.Column26.HeaderText = "Printed";
			this.Column26.Name = "Column26";
			this.Column26.ReadOnly = true;
			this.Column26.Visible = false;
			this.btnClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnClose.Location = new System.Drawing.Point(802, 565);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new Size(90, 30);
			this.btnClose.TabIndex = 48;
			this.btnClose.Text = "Thoát  [ ESC ]";
			this.btnClose.UseVisualStyleBackColor = true;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.btnPrint.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnPrint.Enabled = false;
			this.btnPrint.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnPrint.Location = new System.Drawing.Point(7, 565);
			this.btnPrint.Name = "btnPrint";
			this.btnPrint.Size = new Size(107, 30);
			this.btnPrint.TabIndex = 46;
			this.btnPrint.Text = "In báo cáo [ F7 ]";
			this.btnPrint.UseVisualStyleBackColor = true;
			this.btnPrint.Click += new EventHandler(this.btnPrint_Click);
			this.btnExportToExcel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnExportToExcel.Enabled = false;
			this.btnExportToExcel.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnExportToExcel.Location = new System.Drawing.Point(118, 565);
			this.btnExportToExcel.Name = "btnExportToExcel";
			this.btnExportToExcel.Size = new Size(102, 30);
			this.btnExportToExcel.TabIndex = 53;
			this.btnExportToExcel.Text = "Xuất File Excel";
			this.btnExportToExcel.UseVisualStyleBackColor = true;
			this.btnExportToExcel.Click += new EventHandler(this.btnExportToExcel_Click);
			this.label1.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.label1.BackColor = Color.White;
			this.label1.BorderStyle = BorderStyle.Fixed3D;
			this.label1.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label1.ForeColor = Color.Black;
			this.label1.Location = new System.Drawing.Point(12, 22);
			this.label1.Name = "label1";
			this.label1.Size = new Size(103, 20);
			this.label1.TabIndex = 33;
			this.label1.Text = "Trong ngày :";
			this.label1.TextAlign = ContentAlignment.MiddleRight;
			this.lblDay.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.lblDay.BackColor = Color.White;
			this.lblDay.BorderStyle = BorderStyle.Fixed3D;
			this.lblDay.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.lblDay.ForeColor = Color.Black;
			this.lblDay.Location = new System.Drawing.Point(121, 22);
			this.lblDay.Name = "lblDay";
			this.lblDay.Size = new Size(78, 20);
			this.lblDay.TabIndex = 34;
			this.lblDay.Text = "-:-";
			this.lblDay.TextAlign = ContentAlignment.MiddleLeft;
			this.lblSumMoneyInDay.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.lblSumMoneyInDay.BackColor = Color.White;
			this.lblSumMoneyInDay.BorderStyle = BorderStyle.Fixed3D;
			this.lblSumMoneyInDay.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.lblSumMoneyInDay.ForeColor = Color.Black;
			this.lblSumMoneyInDay.Location = new System.Drawing.Point(205, 21);
			this.lblSumMoneyInDay.Name = "lblSumMoneyInDay";
			this.lblSumMoneyInDay.Size = new Size(103, 20);
			this.lblSumMoneyInDay.TabIndex = 35;
			this.lblSumMoneyInDay.Text = "-:-";
			this.lblSumMoneyInDay.TextAlign = ContentAlignment.MiddleRight;
			this.lblSumMonneyInMonth.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.lblSumMonneyInMonth.BackColor = Color.White;
			this.lblSumMonneyInMonth.BorderStyle = BorderStyle.Fixed3D;
			this.lblSumMonneyInMonth.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.lblSumMonneyInMonth.ForeColor = Color.Black;
			this.lblSumMonneyInMonth.Location = new System.Drawing.Point(205, 48);
			this.lblSumMonneyInMonth.Name = "lblSumMonneyInMonth";
			this.lblSumMonneyInMonth.Size = new Size(103, 20);
			this.lblSumMonneyInMonth.TabIndex = 38;
			this.lblSumMonneyInMonth.Text = "-:-";
			this.lblSumMonneyInMonth.TextAlign = ContentAlignment.MiddleRight;
			this.lblMonth.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.lblMonth.BackColor = Color.White;
			this.lblMonth.BorderStyle = BorderStyle.Fixed3D;
			this.lblMonth.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.lblMonth.ForeColor = Color.Black;
			this.lblMonth.Location = new System.Drawing.Point(121, 49);
			this.lblMonth.Name = "lblMonth";
			this.lblMonth.Size = new Size(78, 20);
			this.lblMonth.TabIndex = 37;
			this.lblMonth.Text = "-:-";
			this.lblMonth.TextAlign = ContentAlignment.MiddleLeft;
			this.label6.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.label6.BackColor = Color.White;
			this.label6.BorderStyle = BorderStyle.Fixed3D;
			this.label6.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 163);
			this.label6.ForeColor = Color.Black;
			this.label6.Location = new System.Drawing.Point(12, 49);
			this.label6.Name = "label6";
			this.label6.Size = new Size(103, 20);
			this.label6.TabIndex = 36;
			this.label6.Text = "Trong tháng :";
			this.label6.TextAlign = ContentAlignment.MiddleRight;
			this.groupBox1.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.groupBox1.Controls.Add(this.lblSumMonneyInMonth);
			this.groupBox1.Controls.Add(this.lblSumMoneyInDay);
			this.groupBox1.Controls.Add(this.lblMonth);
			this.groupBox1.Controls.Add(this.label1);
			this.groupBox1.Controls.Add(this.label6);
			this.groupBox1.Controls.Add(this.lblDay);
			this.groupBox1.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.groupBox1.Location = new System.Drawing.Point(572, 5);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new Size(320, 81);
			this.groupBox1.TabIndex = 54;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Doanh số bán hàng";
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(900, 600);
			base.Controls.Add(this.groupBox1);
			base.Controls.Add(this.btnExportToExcel);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.btnPrint);
			base.Controls.Add(this.groupBox3);
			base.Controls.Add(this.dgvBill);
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
			//base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			base.Name = "frmRepOutputRetail";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "BÁO CÁO BÁN HÀNG";
			base.Load += new EventHandler(this.frmOutputRetail_Load);
			base.KeyDown += new KeyEventHandler(this.frmOutputRetail_KeyDown);
			this.groupBox3.ResumeLayout(false);
			this.groupBox3.PerformLayout();
			((ISupportInitialize)this.dgvBill).EndInit();
			this.groupBox1.ResumeLayout(false);
			base.ResumeLayout(false);
		}
		public frmRepOutputRetail()
		{
			this.InitializeComponent();
		}
		private void frmOutputRetail_Load(object sender, EventArgs e)
		{
			this.objFunc.LoadComboBox("SELECT * FROM [TabUser] ORDER BY [FullName]", this.cbbAccount, "UserName", "FullName");
			try
			{
				this.cbbAccount.SelectedValue = this.userName;
			}
			catch
			{
			}
			this.lblDay.Text = this.dtpSelectMonth.Text;
			this.lblMonth.Text = this.dtpSelectMonth.Value.Month.ToString() + "/" + this.dtpSelectMonth.Value.Year.ToString();
			this.getBill();
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void frmOutputRetail_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
			else
			{
				if (e.KeyCode == Keys.F7)
				{
					this.btnPrint.PerformClick();
				}
			}
		}
		private void getBill()
		{
			this.objTableBill = null;
			string text;
			if (this.ckbSelectAccount.Checked)
			{
				text = "";
			}
			else
			{
				text = " AND [UserName] = '" + this.cbbAccount.SelectedValue.ToString() + "' ";
			}
			this.dgvBill.AutoGenerateColumns = false;
			SqlConnection sqlConnection = new SqlConnection(this.objFunc.strConnectionString);
			string cmdText = string.Concat(new object[]
			{
				"SELECT * FROM [TabBill] WHERE TypeInput = 'OUT4' ",
				text,
				"AND datepart(Day,CreateDate) = ",
				this.dtpSelectMonth.Value.Day.ToString(),
				" AND datepart(Month,CreateDate) = ",
				this.dtpSelectMonth.Value.Month,
				" AND datepart(Year,CreateDate) = ",
				this.dtpSelectMonth.Value.Year,
				" ORDER BY [CreateDate] DESC"
			});
			SqlCommand selectCommand = new SqlCommand(cmdText, sqlConnection);
			SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(selectCommand);
			DataSet dataSet = new DataSet();
			sqlConnection.Open();
			sqlDataAdapter.Fill(dataSet);
			this.objTableBill = dataSet.Tables[0];
			this.dgvBill.DataSource = this.objTableBill;
			string cmdText2 = string.Concat(new object[]
			{
				"SELECT SUM(TotalMoney) AS MoneyInMonth FROM [TabBill] WHERE TypeInput = 'OUT4' ",
				text,
				"AND datepart(Month,CreateDate) = ",
				this.dtpSelectMonth.Value.Month,
				" AND datepart(Year,CreateDate) = ",
				this.dtpSelectMonth.Value.Year
			});
			SqlCommand sqlCommand = new SqlCommand(cmdText2, sqlConnection);
			SqlDataReader sqlDataReader = sqlCommand.ExecuteReader();
			float num = 0f;
			while (sqlDataReader.Read())
			{
				try
				{
					num = float.Parse(sqlDataReader["MoneyInMonth"].ToString());
				}
				catch
				{
					num = 0f;
				}
			}
			sqlDataReader.Close();
			sqlConnection.Close();
			sqlConnection.Dispose();
			sqlDataAdapter.Dispose();
			dataSet.Dispose();
			if (this.dgvBill.Rows.Count > 0)
			{
				float num2 = 0f;
				for (int i = 0; i < this.dgvBill.Rows.Count; i++)
				{
					num2 += float.Parse(this.dgvBill.Rows[i].Cells["Column10"].Value.ToString());
				}
				this.lblSumMoneyInDay.Text = string.Format(Program.lenAffterDecimal, num2);
				this.lblSumMonneyInMonth.Text = string.Format(Program.lenAffterDecimal, num);
				this.btnPrint.Enabled = true;
				this.btnExportToExcel.Enabled = true;
			}
			else
			{
				this.btnPrint.Enabled = false;
				this.btnExportToExcel.Enabled = false;
				this.lblSumMoneyInDay.Text = "0";
				this.lblSumMonneyInMonth.Text = "0";
			}
		}
		private void btnPrint_Click(object sender, EventArgs e)
		{
			frmRepOutputRetailBill.objTable = null;
			frmRepOutputRetailBill.objTable = this.objTableBill;
			frmRepOutputRetailView frmRepOutputRetailView = new frmRepOutputRetailView();
			if (this.ckbSelectAccount.Checked)
			{
				frmRepOutputRetailView.fullName = "Nhân viên bán hàng : " + this.cbbAccount.Text;
			}
			else
			{
				frmRepOutputRetailView.fullName = "Nhân viên bán hàng : Tất cả";
			}
			frmRepOutputRetailView.dateTime = string.Concat(new string[]
			{
				"Ngày ",
				this.dtpSelectMonth.Value.Day.ToString(),
				" tháng ",
				this.dtpSelectMonth.Value.Month.ToString(),
				" ngày ",
				this.dtpSelectMonth.Value.Year.ToString()
			});
			frmRepOutputRetailView.allMoney = this.lblSumMoneyInDay.Text.Replace(",", "");
			frmRepOutputRetailView.ShowDialog();
		}
		private void dtpSelectMonth_ValueChanged(object sender, EventArgs e)
		{
			this.lblDay.Text = this.dtpSelectMonth.Text;
			this.lblMonth.Text = this.dtpSelectMonth.Value.Month.ToString() + "/" + this.dtpSelectMonth.Value.Year.ToString();
			this.getBill();
		}
		private void cbbAccount_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.getBill();
		}
		private void ckbSelectAccount_CheckedChanged(object sender, EventArgs e)
		{
			if (this.ckbSelectAccount.Checked)
			{
				this.cbbAccount.Enabled = false;
			}
			else
			{
				this.cbbAccount.Enabled = true;
			}
			this.getBill();
		}
		private void btnExportToExcel_Click(object sender, EventArgs e)
		{
			try
			{
				frmRepOutputRetailBill.objTable = new DataTable();
				frmRepOutputRetailBill.objTable = this.objTable;
				ActiveReport3 activeReport = new frmRepOutputRetailBill();
				activeReport.Run();
				XlsExport xlsExport = new XlsExport();
				SaveFileDialog saveFileDialog = new SaveFileDialog();
				saveFileDialog.ShowDialog();
				string text = saveFileDialog.FileName;
				if (text != "")
				{
					if (!text.ToUpper().Contains(".XLS"))
					{
						text += ".xls";
					}
					xlsExport.Export(activeReport.Document, text);
					MessageBox.Show("Hệ thống đã hoàn thành việc xuất dữ liệu ra file Excel", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				}
				else
				{
					MessageBox.Show("Bạn chưa chọn đường dẫn và tên file cần xuất!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				}
			}
			catch
			{
			}
		}
	}
}
